import request from '@/utils/axiosUtil'
import { ShopCart } from '@/piniastore/shopcart/state'

// 购物车相关API
class ShopCartAPI {
  static shopcartAPI = new ShopCartAPI()

  // 根据用户id获取相关购物车列表
  getShopCartList(userid: number) {
    return request.get(`/shopcartmodule/findCurUseShopCartLst/${userid}`, false)
  }

  // 添加图书到购物车
  addBookToShopCart(shopcart: ShopCart) {
    return request.post('/shopcartmodule/addBookToShopCart', false, shopcart)
  }

  // 更新购物车中图书购买数量
  appOrSubtrBookFrmShopCart(shopCart: ShopCart) {
    return request.post('/shopcartmodule/appOrSubtrBookFrmShopCart', false, shopCart)
  }

  // 根据购物车id从购物车表中删除一本书
  delBookFrmSC(shopcartid: number) {
    return request.delete(`/shopcartmodule/delBookShopCart/${shopcartid}`, false)
  }
}

export default ShopCartAPI.shopcartAPI
